home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Patches 1998 April / IRIX 6.4 Recommended-Required Patches April 1998.img / dist / 6.4_POSIX / patchSG0002420.idb / usr / include / pthread.h.z / pthread.h
C/C++ Source or Header  |  1997-12-03  |  8KB  |  258 lines

  1. #ifndef _PTHREAD_H_
  2. #define _PTHREAD_H_
  3.  
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7.  
  8. /**************************************************************************
  9.  *                                      *
  10.  *          Copyright (C) 1996 Silicon Graphics, Inc.          *
  11.  *                                      *
  12.  *  These coded instructions, statements, and computer programs  contain  *
  13.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  14.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  15.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  16.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  17.  *                                      *
  18.  **************************************************************************/
  19.  
  20. /*
  21.  * POSIX 1C Threads header file
  22.  */
  23.  
  24. #include <stddef.h>
  25. #include <sys/time.h>
  26. #include <signal.h>
  27.  
  28.  
  29. /*
  30.  * Primitive system data types
  31.  */
  32. typedef __uint32_t         pthread_t;    /* pthread identifier */
  33.  
  34. #ifdef _PTHREAD_EXECUTIVE
  35. typedef struct ptattr        pthread_attr_t;
  36. typedef struct mtx        pthread_mutex_t;
  37. typedef struct mtxattr        pthread_mutexattr_t;
  38. typedef struct cv        pthread_cond_t;
  39. typedef struct cvattr        pthread_condattr_t;
  40. typedef int            pthread_key_t;
  41. typedef volatile int        pthread_once_t;
  42. #else
  43. typedef struct { long __D[5]; } pthread_attr_t;        /* pthread attributes */
  44. typedef struct { long __D[8]; } pthread_mutex_t;    /* mutex data */
  45. typedef struct { long __D[2]; } pthread_mutexattr_t;    /* mutex attributes */
  46. typedef struct { long __D[8]; } pthread_cond_t;        /* condvar data */
  47. typedef struct { long __D[2]; } pthread_condattr_t;    /* condvar attributes */
  48. typedef int    pthread_key_t;        /* thread specific data key */
  49. typedef int    pthread_once_t;        /* dynamic package initialization */
  50. #endif /* !_PTHREAD_EXECUTIVE */
  51.  
  52. struct sched_param;
  53.  
  54. #undef _POSIX_THREAD_PROCESS_SHARED
  55. #define PTHREAD_PROCESS_SHARED    0
  56. #define PTHREAD_PROCESS_PRIVATE    1
  57.  
  58.  
  59. /*
  60.  * Threads
  61.  */
  62.  
  63. /* Thread creation attributes
  64.  */
  65. #define _POSIX_THREAD_ATTR_STACKSIZE    1
  66. #define _POSIX_THREAD_ATTR_STACKADDR    1
  67. int pthread_attr_init(pthread_attr_t *);
  68. int pthread_attr_destroy(pthread_attr_t *);
  69. int pthread_attr_setstacksize(pthread_attr_t *, size_t);
  70. int pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
  71. int pthread_attr_setstackaddr(pthread_attr_t *, void *);
  72. int pthread_attr_getstackaddr(const pthread_attr_t *, void **);
  73. int pthread_attr_setdetachstate(pthread_attr_t *, int);
  74. int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
  75.  
  76. #define PTHREAD_CREATE_JOINABLE    0
  77. #define PTHREAD_CREATE_DETACHED    1
  78.  
  79. /* Thread scheduling attributes
  80.  */
  81. #define _POSIX_THREAD_PRIORITY_SCHEDULING    1
  82. int pthread_attr_setscope(pthread_attr_t *, int);
  83. int pthread_attr_getscope(const pthread_attr_t *, int *);
  84. int pthread_attr_setinheritsched(pthread_attr_t *, int);
  85. int pthread_attr_getinheritsched(const pthread_attr_t *, int *);
  86. int pthread_attr_setschedpolicy(pthread_attr_t *, int);
  87. int pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
  88. int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *);
  89. int pthread_attr_getschedparam(const pthread_attr_t *, struct sched_param *);
  90.  
  91. #define PTHREAD_SCOPE_PROCESS    0
  92. #define PTHREAD_SCOPE_SYSTEM    1
  93.  
  94. #define PTHREAD_EXPLICIT_SCHED    0
  95. #define PTHREAD_INHERIT_SCHED    1
  96.  
  97. /* Thread creation and control
  98.  */
  99. int pthread_create(pthread_t *, pthread_attr_t *, void *(*)(void *), void *);
  100. int pthread_join(pthread_t, void **);
  101. int pthread_detach(pthread_t);
  102. void pthread_exit(void *);
  103. pthread_t pthread_self(void);
  104. #define pthread_equal(t1, t2) ((t1) == (t2))
  105. int pthread_kill(pthread_t, int);
  106. int pthread_sigmask(int, const sigset_t *, sigset_t *);
  107.  
  108. int pthread_once(pthread_once_t *, void (*)(void));
  109. #define PTHREAD_ONCE_INIT    0
  110.  
  111. /* Thread scheduling control
  112.  */
  113. int pthread_getschedparam(pthread_t, int *, struct sched_param *);
  114. int pthread_setschedparam(pthread_t, int, const struct sched_param *);
  115. int pthread_getconcurrency(void);
  116. int pthread_setconcurrency(int);
  117.  
  118. /* Thread cancellation
  119.  */
  120. int pthread_cancel(pthread_t);
  121. int pthread_setcancelstate(int, int *);
  122. int pthread_setcanceltype(int, int *);
  123. void pthread_testcancel(void);
  124.  
  125. struct __pthread_cncl_hdlr    **__pthread_cancel_list(void);
  126. struct __pthread_cncl_hdlr {
  127.     struct __pthread_cncl_hdlr    *__ptch_next;
  128.     void                (*__ptch_func)(void *);
  129.     void                *__ptch_arg;
  130. };
  131.  
  132. #define pthread_cleanup_push(func, arg)            \
  133. {    /* start of cleanup scope */            \
  134.     struct __pthread_cncl_hdlr __ptch;        \
  135.     struct __pthread_cncl_hdlr **__ptch_list;    \
  136.     __ptch.__ptch_func = func;            \
  137.     __ptch.__ptch_arg = arg;            \
  138.     __ptch_list = __pthread_cancel_list();        \
  139.     __ptch.__ptch_next = *__ptch_list;        \
  140.     *__ptch_list = &__ptch
  141.  
  142. #define pthread_cleanup_pop(exec)                \
  143.     *__ptch_list = __ptch.__ptch_next;            \
  144.     if (exec) {                        \
  145.         (*__ptch.__ptch_func)(__ptch.__ptch_arg);    \
  146.     }                            \
  147. }    /* end of cleanup scope */
  148.  
  149. #define PTHREAD_CANCELED        ((void *)(1L))
  150.  
  151. #define PTHREAD_CANCEL_DISABLE        0
  152. #define PTHREAD_CANCEL_ENABLE        1
  153. #define PTHREAD_CANCEL_ASYNCHRONOUS    0
  154. #define PTHREAD_CANCEL_DEFERRED        1
  155.  
  156.  
  157. /*
  158.  * Mutexes
  159.  */
  160.  
  161. /* Mutex initialisation attributes
  162.  */
  163. int pthread_mutexattr_init(pthread_mutexattr_t *);
  164. int pthread_mutexattr_destroy(pthread_mutexattr_t *);
  165. #undef _POSIX_THREAD_PROCESS_SHARED
  166. #ifdef _POSIX_THREAD_PROCESS_SHARED
  167. int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
  168. int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
  169. #endif
  170.  
  171. /* Mutex scheduling attributes
  172.  */
  173. int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
  174. int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *, int *);
  175. int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
  176. int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *, int *);
  177.  
  178. #define _POSIX_THREAD_PRIO_INHERIT    1
  179. #define _POSIX_THREAD_PRIO_PROTECT    1
  180. #define PTHREAD_PRIO_NONE    0    /* priority unaffected */
  181. #define PTHREAD_PRIO_INHERIT    1    /* priority inheritance */
  182. #define PTHREAD_PRIO_PROTECT    2    /* priority ceiling */
  183.  
  184. /* Mutex creation and control
  185.  */
  186. int pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t *);
  187. int pthread_mutex_destroy(pthread_mutex_t *);
  188.  
  189. int pthread_mutex_lock(pthread_mutex_t *);
  190. int pthread_mutex_trylock(pthread_mutex_t *);
  191. int pthread_mutex_unlock(pthread_mutex_t *);
  192.  
  193. #define PTHREAD_MUTEX_INITIALIZER    { 0 }
  194.  
  195. /* Mutex scheduling control
  196.  */
  197. int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);
  198. int pthread_mutex_getprioceiling(const pthread_mutex_t *, int *);
  199.  
  200.  
  201. /*
  202.  * Condition Variables
  203.  */
  204.  
  205. /* Condition variable initialization attributes
  206.  */
  207. int pthread_condattr_init(pthread_condattr_t *);
  208. int pthread_condattr_destroy(pthread_condattr_t *);
  209. #ifdef _POSIX_THREAD_PROCESS_SHARED
  210. int pthread_condattr_getpshared(const pthread_condattr_t *, int *);
  211. int pthread_condattr_setpshared(pthread_condattr_t *, int);
  212. #endif
  213.  
  214. /* Condition variable operations
  215.  */
  216. int pthread_cond_init(pthread_cond_t *, pthread_condattr_t *);
  217. int pthread_cond_destroy(pthread_cond_t *);
  218.  
  219. int pthread_cond_signal(pthread_cond_t *);
  220. int pthread_cond_broadcast(pthread_cond_t *);
  221. int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
  222. int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *,
  223.                const struct timespec *);
  224.  
  225. #define PTHREAD_COND_INITIALIZER    { 0 }
  226.  
  227.  
  228. /*
  229.  * Thread-specific data
  230.  */
  231.  
  232. int pthread_key_create(pthread_key_t *, void (*)(void *));
  233. int pthread_setspecific(pthread_key_t, const void *);
  234. void *pthread_getspecific(pthread_key_t);
  235. int pthread_key_delete(pthread_key_t);
  236.  
  237.  
  238. /*
  239.  * Miscellaneous
  240.  */
  241.  
  242. int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
  243.  
  244. /* Short term patch: destined for <sys/resource.h>
  245.  */
  246. #define RLIMIT_PTHREAD    8
  247.  
  248. #ifndef    _SGI_MP_SOURCE
  249. #define _SGI_MP_SOURCE
  250. #endif
  251.  
  252.  
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256.  
  257. #endif /* !_PTHREAD_H_ */
  258.